package at.ac.univie.zsu.aguataplan.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

/**
 * @author gerry
 * 
 */
@Entity
public class Coach extends Person {

	@OneToMany(cascade = CascadeType.ALL)
	private Set<WorkingDescription> refWorkingDescription = new HashSet<WorkingDescription>();

	@ManyToMany(cascade = CascadeType.ALL)
	private Set<Education> refEducation = new HashSet<Education>();

	@ManyToMany(cascade = CascadeType.ALL)
	private Set<Coaching> refCoaching = new HashSet<Coaching>();

	@OneToMany(cascade = CascadeType.ALL)
	private Set<DetectedEvent> refDetectedEvent = new HashSet<DetectedEvent>();

	@OneToMany(cascade = CascadeType.ALL)
	private Set<BallPosession> refBallPosession = new HashSet<BallPosession>();

	// ----------------------------------------------------
	// CONSTRUCTOR
	// ----------------------------------------------------

	public Coach() {

	}

	// ----------------------------------------------------
	// METHODS
	// ----------------------------------------------------

	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("Birthday: ").append(getBirthday()).append(", ");
		sb.append("FirstName: ").append(getFirstName()).append(", ");
		sb.append("Id: ").append(getId()).append(", ");
		sb.append("LastName: ").append(getLastName()).append(", ");
		sb.append("Phone: ").append(getPhone()).append(", ");
		sb.append("RefBallPosession: ")
				.append(getRefBallPosession() == null ? "null"
						: getRefBallPosession().size()).append(", ");
		sb.append("RefCoaching: ")
				.append(getRefCoaching() == null ? "null" : getRefCoaching()
						.size()).append(", ");
		sb.append("RefDetectedEvent: ")
				.append(getRefDetectedEvent() == null ? "null"
						: getRefDetectedEvent().size()).append(", ");
		sb.append("RefEducation: ")
				.append(getRefEducation() == null ? "null" : getRefEducation()
						.size()).append(", ");
		sb.append("RefPersonEMail: ")
				.append(getRefPersonEMail() == null ? "null"
						: getRefPersonEMail().size()).append(", ");
		sb.append("RefPersonWeb: ")
				.append(getRefPersonWeb() == null ? "null" : getRefPersonWeb()
						.size()).append(", ");
		sb.append("RefWorkingDescription: ")
				.append(getRefWorkingDescription() == null ? "null"
						: getRefWorkingDescription().size()).append(", ");
		sb.append("Sex: ").append(getSex()).append(", ");
		sb.append("Version: ").append(getVersion());
		return sb.toString();
	}

	// ----------------------------------------------------
	// GETTER & SETTER
	// ----------------------------------------------------

	public Set<WorkingDescription> getRefWorkingDescription() {
		return refWorkingDescription;
	}

	public void setRefWorkingDescription(
			Set<WorkingDescription> refWorkingDescription) {
		this.refWorkingDescription = refWorkingDescription;
	}

	public Set<Education> getRefEducation() {
		return refEducation;
	}

	public void setRefEducation(Set<Education> refEducation) {
		this.refEducation = refEducation;
	}

	public Set<Coaching> getRefCoaching() {
		return refCoaching;
	}

	public void setRefCoaching(Set<Coaching> refCoaching) {
		this.refCoaching = refCoaching;
	}

	public Set<DetectedEvent> getRefDetectedEvent() {
		return refDetectedEvent;
	}

	public void setRefDetectedEvent(Set<DetectedEvent> refDetectedEvent) {
		this.refDetectedEvent = refDetectedEvent;
	}

	public Set<BallPosession> getRefBallPosession() {
		return refBallPosession;
	}

	public void setRefBallPosession(Set<BallPosession> refBallPosession) {
		this.refBallPosession = refBallPosession;
	}

}
